@include('admin.header')
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="/rbac/menuList">菜单栏列表</a></li>
			<li  class="active"><a href="javascript:void(0)" target="_self">@if($id > 0) 编辑菜单栏 @else 添加菜单栏 @endif</a></li>
		</ul>
		<form method="post" class="form-horizontal js-category-add">
			<div class="row-fluid">
				<table class="table table-bordered">
					<tr>
						<th>上级菜单栏</th>
						<td>
							<select id="pid"  name="pid">
								<option value="0">请选择菜单栏</option>
								@foreach($category as $key => $vo)
									<option value="{{$vo->id}}" @if($id>0){@if($vo->id == $data->pid){echo selected="selected";} @endif}@endif>{{$vo->title}}</option>
								@endforeach
							</select>
						</td>
					</tr>
					<tr>
						<th>菜单栏中文名称</th>
						<td>
							<input type="text" style="width:400px;" name="title"  value="{{$data->title or '' }}" placeholder="菜单栏中文名称"/>
						</td>
					</tr>
					<tr>
						<th>菜单栏唯一标识</th>
						<td>
							<input type="text" style="width:400px;" name="name"  value="{{$data->name or '' }}" placeholder="菜单栏唯一标识"/>
						</td>
					</tr>
					<tr>
						<th>状态</th>
						<td>
							<select id="status"  name="status">
								<option value="1" @if($action == 'edit') @if($data->status == 1) selected="selected" @endif @endif>正常</option>
								<option value="0" @if($action == 'edit') @if($data->status == 0) selected="selected" @endif @endif>禁用</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>菜单栏是否需要验证</th>
						<td>
							<select id="verify"  name="verify">
								<option value="1" @if($action == 'edit') @if($data->status == 1) selected="selected" @endif @endif>是</option>
								<option value="0" @if($action == 'edit') @if($data->status == 0) selected="selected" @endif @endif>否</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>菜单栏是否显示</th>
						<td>
							<select id="is_show"  name="is_show">
								<option value="1" @if($action == 'edit') @if($data->status == 1) selected="selected" @endif @endif>是</option>
								<option value="0" @if($action == 'edit') @if($data->status == 0) selected="selected" @endif @endif>否</option>
							</select>
						</td>
					</tr>
						<tr>
						<th>菜单栏排序</th>
						<td>
							<input type="text" style="width:400px;" name="sorts"  value="{{$data->sorts or '' }}" placeholder="请输入菜单栏排序,默认255"/>
						</td>
					</tr>
				</table>
			</div>
			<div class="form-actions">
				<input type="hidden" name="id" value="{{$id or 0}}"/>
				<input type="hidden" name="_token"  value="{{csrf_token()}}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{{asset('rbac/menuList')}}">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="/static/js/common.js"></script>
	<script type="text/javascript" src="/static/js/validate/validate.js"></script>
	<script type="text/javascript" src="/static/js/layer/layer.js"></script>
	<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>
	<script type="text/javascript">
		$(function() {
			$(".js-category-add").validate({
				rules: {
					name: {
						required: true
					}
				},
				messages: {
					name: {
						required: "菜单栏唯一标识"
					}
				},
				submitHandler: function () {
					$.post("/rbac/menu{{$action}}",$('.js-category-add').serialize(), function (msg) {
						if (msg.status == 1) {
							layer.confirm(msg.info, {
								btn: ['确定']
							}, function(){
								@if($action == 'Add')
									window.location.href="{{asset('rbac/menuList')}}";
								@else
									window.location.href="{{asset('rbac/menuEdit')}}";
								@endif
							});
						} else {
							showMsg(msg.info);
						}
					}, 'json');
					return false;
				}
			});
		});
		/**
		 * layer提示
		 */
		function showMsg(msg){
			layer.alert(msg, {
				title: '提示',
				icon: 2,
			});
		}
	</script>
</body>
</html>